<template>
  <div id="myHeader">
    <img :src="'http://www.rushmc.top/' + this.photo" alt="" id="avatar" />

    <div id="wrapper">
      <div>
        <span class="username">{{ username }}</span>
        <router-link to="/myDouban/modifyInfo">(编辑个人信息)</router-link>
      </div>

      <nav>
        <router-link
          v-for="(item, index) in this.links"
          :key="index"
          :to="item.url"
          >{{ item.value }}
        </router-link>
      </nav>
    </div>
  </div>
</template>

<script>
import "../assets/style/default.css";
export default {
  name: "myHeader",

  data() {
    return {
      //用户名
      username: "",
      photo: "",
      links: [
        { value: "我的动态", url: "/myDouban/myDynamic" },
        { value: "发表动态", url: "/myDouban/pubDynamic" },
      ]
    };
  },

  mounted() {
    //记录用户头像
    this.photo = sessionStorage.getItem("photo");
    //记录用户名
    this.username =
      sessionStorage.getItem("username") != null
        ? sessionStorage.getItem("username")
        : document.cookie.split(";")[0].split("=")[1];
  },
  methods: {}
};
</script>

<style  scoped>
#myHeader {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}
#wrapper {
  width: 58rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  /* background: pink; */
}
#wrapper div {
  height: 6rem;
  /* width: 20rem; */
  /* background: lightblue; */
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#wrapper .username {
  font-size: 1.8rem;
  font-weight: bold;
  margin-bottom: 0.3rem;
}
#wrapper div a {
  color: #999999;
  font-size: 0.9rem;
  font-style: italic;
  cursor: pointer;
}
#wrapper div a:hover {
  color: #b3b3b3;
}
#wrapper nav {
  height: 2rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
#wrapper nav a {
  margin-right: 2rem;
  color: #0066cc;
}
#wrapper nav a:hover {
  background: #0066cc;
  color: white;
}
#avatar {
  width: 6rem;
  height: 6rem;
  margin-right: 2rem;
  /* background: pink; */
}
</style>